// app.js
App({
  request: function (_methods, url, data, callback) {
    let hd = {
      // 'Content-Type': 'application/x-www-form-urlencoded',
		}
    if(data['token']){
      hd['token'] = data['token']
    }
    if(wx.getStorageSync('token')){
      hd['token'] = wx.getStorageSync('token')
    }
    data.token = wx.getStorageSync('token');
    let host = "https://adminii.sengain.top/fishApi";
    wx.request({
      url: host + url,
      method: _methods,
      header: hd,
      data: data,
      dataType: 'json',
      success: (res) => {
        if (res.data.code == 401 || (res.data.code==500 && res.data.msg=="请登录")) {
          console.log("请登录", url)
          wx.showToast({
            title: '请登录',
            icon: 'none'
          })
          wx.removeStorageSync('token')
          setTimeout(() => {
            wx.reLaunch({
              url: '/pages/logs/logs',
            })
          }, 1000)
        } else {
          typeof callback == "function" && callback(res, "");
        }
      },
      fail: (err) => {
        typeof callback == "function" && callback(err, "");
      }
    });
  },
  newDate:function(v,v1,v2,v3,v4,v5){
    let al = arguments.length
    if(al==0){
      return new Date();
    }
    if(al==1 && typeof(v)=='string'){
      return new Date(v.toString().replace(/-/g,'/'))
    }
    if(al==1){
      return new Date(v);
    }
    if(al==2){
      return new Date(v,v1)
    }
    if(al==3){
      return new Date(v,v1,v2)
    }
    if(al==4){
      return new Date(v,v1,v2,v3)
    }
    if(al==5){
      return new Date(v,v1,v2,v3,v4)
    }
    if(al==6){
      return new Date(v,v1,v2,v3,v4,v5)
    }
  }
})
